//
//  HMNavigationController.swift
//  Weibo-walker
//
//  Created by 郭彬 on 16/3/3.
//  Copyright © 2016年 guobin. All rights reserved.
//

import UIKit

class HMNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    //重写跳转的控制器方法
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count > 0 {
            var title = "返回"
            
            if childViewControllers.count == 1 {
                title = childViewControllers.first?.title ?? "返回"
            }
            
            //添加自己的逻辑
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageNamed: "navigationbar_back_withtext", title: title, target: self, action: "back")

            viewController.hidesBottomBarWhenPushed = true

        }
        
        super.pushViewController(viewController, animated: true)
    }
    
    func back(){
        
        popViewControllerAnimated(true)
        
    }
        
        
    
    //设置导航控制器左右两边的UINavigation
    
   }
